<!DOCTYPE html>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;

%>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="IMG/favicon.ico">


    <title>任务规则配置</title>

    <!-- Bootstrap core CSS -->
    <link href="static/css/dist/css/bootstrap.min.css?v=1" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="static/css/dist/css/bootstrap-theme.min.css" rel="stylesheet">
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="static/css/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="static/css/theme.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="static/css/loading.css" rel="stylesheet">

    <!--[if lt IE 9]>
    <script src="static/css/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="static/css/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>

    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>


    <![endif]-->
</head>

<body role="document">


<!-- Fixed navbar -->
<jsp:include page="top.jsp" flush="true"/>

<div class="container">

<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
      <span style="font-family:微软雅黑;">
      任务规则配置
        <button type="button" id="loadButton" name="loadButton" data-toggle="modal" data-target="#addModal"
                class="btn btn-default">
            新增
        </button>
           <span style="color:red">${msg}</span>
      </span>
</div>
<div class="panel-body">
    <p><span style="font-family:微软雅黑;">此页面配置发送任务，包括EMAIL分组选择、数据源选择等等。注意：任务名是唯一的</span></p>
</div>

<!--Model ALL-->
<!-- Modal -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="addModalLabel">添加任务配置</h4>
            </div>
            <div class="modal-body" style="font-family:微软雅黑;">


                <form class="form-horizontal" action="<%= basePath %>/taskAdd" method="post"
                      enctype="multipart/form-data"
                      name="addData">
                    <div class="form-group">
                        <label for="taskName" class="col-sm-2 control-label">任务名</label>

                        <div class="col-sm-10">
                            <input name="taskName" type="text" class="form-control" id="taskName" placeholder="任务名">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="cronExpression" class="col-sm-2 control-label">发送时间</label>

                        <div class="col-sm-10">
                            <input name="cronExpression" type="text" class="form-control" id="cronExpression"
                                   placeholder="发送时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="taskDesc" class="col-sm-2 control-label">任务描述</label>

                        <div class="col-sm-10">
                            <input name="taskDesc" type="text" class="form-control" id="taskDesc" placeholder="任务描述">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">启动方式</label>
                        &nbsp;&nbsp;
                        <label class="radio-inline">
                            <input type="radio" name="isAutoRun" value="1" checked> 自动执行
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="isAutoRun" value="0"> 手动执行
                        </label>
                    </div>

                    <div class="form-group">
                        <label for="dataSource" class="col-sm-2 control-label">数据源</label>

                        <div class="col-sm-10">
                            <select class="form-control" name="dataSource" id="dataSource">

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="ExcelFile" class="col-sm-2 control-label">上传表格</label>

                        <div class="col-sm-10">
                            <input type="file" id="excelFile" name="excelFile">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sheetNames" class="col-sm-2 control-label">需要发送sheet名称</label>

                        <div class="col-sm-10">
                            <input type="text" id="sheetNames" class="form-control" name="sheetNames"
                                   placeholder="填写EXCEL中的需要发送的sheet名称，如有多个Sheet，用*分割，如：Sheet1*Sheet2">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">邮件选项</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" id="isSendEmail" name="isSendEmail" onchange="emailSelect(this)" checked> 发送邮件
                        </label>
                    </div>
                    <div class="form-group" id="emailGroup">
                        <label for="emailRule" class="col-sm-2 control-label">邮件分组</label>

                        <div class="col-sm-10">
                            <select class="form-control" name="emailRule" id="emailRule">

                            </select>
                        </div>
                    </div>
                    <div class="form-group" id="emailSub">
                        <label for="emailSubject" class="col-sm-2 control-label">邮件主题</label>

                        <div class="col-sm-10">
                            <input name="emailSubject" type="text" class="form-control" id="emailSubject"
                                   placeholder="邮件主题">
                        </div>
                    </div>

                    <div class="form-group" id="emailCont">
                        <label for="emailContent" class="col-sm-2 control-label">邮件内容</label>

                        <div class="col-sm-10">
                            <textarea class="form-control" name="emailContent" name="emailContent" id="emailContent"
                                      rows="2"></textarea>
                        </div>
                    </div>
                    <div class="form-group" id="emailFujian">
                        <label class="col-sm-2 control-label">邮件附件</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" id="isSendExcel" name="isSendExcel" checked> 发送Excel
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" id="isSendPicture" name="isSendPicture" checked>发送图片
                        </label>
                        <span  class="checkbox-inline" style="color:red">[Excel和图片至少选择一项]</span>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">易信选项</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" onchange="yixinSelect(this)" id="isSendYixin" name="isSendYixin">
                            发送易信
                        </label>
                    </div>
                    <div class="form-group" style="display: none;" id="yixin">
                        <label for="sheetNames" class="col-sm-2 control-label">易信接收人</label>

                        <div class="col-sm-10">
                            <input type="text" id="yixinNames" class="form-control" name="yixinNames"
                                   placeholder="填写易信接收人的名字，必须先加好友。如有多个，用,分割，如：张三,李四">
                        </div>
                    </div>
                    <div class="form-group" align="right">
                        <button type="submit" id="addDateButton" name="addDateButton" class="btn btn-default">添加
                        </button>
                        &nbsp;&nbsp;&nbsp;
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="lookModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="lookModalLabel">查看任务配置</h4>
            </div>
            <div class="modal-body" style="font-family:微软雅黑;">
                <form class="form-horizontal" action="#" method="post"
                      enctype="multipart/form-data"
                      name="addData">
                    <div class="form-group">
                        <span class="col-sm-3 "><strong>任务名：</strong></span>

                        <div class="col-sm-9">
                            <span id="taskNameLook"/>
                        </div>

                    </div>

                    <div class="form-group">
                        <span class="col-sm-3 "><strong>发送时间：</strong></span>

                        <div class="col-sm-9">
                            <span id="cronExpressionLook"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <span class="col-sm-3 "><strong>任务描述：</strong></span>

                        <div class="col-sm-9">
                            <span id="taskDescLook"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <span class="col-sm-3"><strong>数据源：</strong></span>

                        <div class="col-sm-9">
                            <span id="dataSourceLook"></span>
                        </div>
                    </div>


                    <div class="form-group">
                        <span class="col-sm-3 "><strong>上传表格：</strong></span>

                        <div class="col-sm-9">
                            <span id="excelFileLookLook"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <span class="col-sm-3 "><strong>需要发送的sheet名称：</strong></span>

                        <div class="col-sm-9">
                            <span id="sheetNamesLook"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3" class="col-sm-2 control-label">邮件选项：</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline" class="col-sm-9">
                            <input type="checkbox" id="lookIsSendEmail" name="lookIsSendEmail"> 发送邮件
                        </label>
                    </div>
                    <div class="form-group">
                        <span class="col-sm-3"><strong>邮件分组：</strong></span>

                        <div class="col-sm-9">
                            <span id="emailRuleLook"></span>
                        </div>
                    </div>
                    <div class="form-group" id="lookEmailSub">
                        <label for="lookEmailSubject" class="col-sm-3">邮件主题：</label>

                        <div class="col-sm-9">
                            <span name="lookEmailSubject"   id="lookEmailSubject"
                                   placeholder="邮件主题"></span>
                        </div>
                    </div>

                    <div class="form-group" id="lookEmailCont">
                        <label  for="lookEmailContent" class="col-sm-3 ">邮件内容：</label>

                        <div class="col-sm-9">
                            <textarea   name="lookEmailContent" id="lookEmailContent"
                                      rows="2"></textarea>
                        </div>
                    </div>
                    <div class="form-group" id="lookEmailFujian">
                        <label class="col-sm-3 ">邮件附件：</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" id="lookIsSendExcel" name="lookIsSendExcel" checked> 发送Excel
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" id="lookIsSendPicture" name="lookIsSendPicture" checked>发送图片
                        </label>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 ">易信选项：</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline"  class="col-sm-9">
                            <input type="checkbox"  id="lookIsSendYixin" name="lookIsSendYixin">
                            发送易信
                        </label>
                    </div>
                    <div class="form-group" style="display: none;" id="lookYixin">
                        <label for="lookYixinNames" class="col-sm-3">易信接收人：</label>

                        <div class="col-sm-9">
                            <span id="lookYixinNames"  name="lookYixinNames"
                                  ></span>
                        </div>
                    </div>

                </form>

            </div>

        </div>
    </div>
</div>


<div class="modal fade" id="alterModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="alterModalLabel">修改任务规则</h4>
            </div>
            <div class="modal-body" style="font-family:微软雅黑;">
                <form class="form-horizontal" action="<%= basePath %>/taskAlter"  method="post" enctype="multipart/form-data"
                      name="taskAlter">
                    <div class="form-group">
                        <label for="alterTaskName" class="col-sm-2 control-label">任务名</label>

                        <div class="col-sm-10">
                            <input name="alterTaskName" type="text" class="form-control"  id="alterTaskName" placeholder="任务名">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="alterCronExpression" class="col-sm-2 control-label">发送时间</label>

                        <div class="col-sm-10">
                            <input name="alterCronExpression" type="text" class="form-control" id="alterCronExpression"
                                   placeholder="发送时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="alterTaskDesc" class="col-sm-2 control-label">任务描述</label>

                        <div class="col-sm-10">
                            <input name="alterTaskDesc" type="text" class="form-control" id="alterTaskDesc" placeholder="任务描述">
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="alterDataSource" class="col-sm-2 control-label">数据源</label>

                        <div class="col-sm-10">
                            <select class="form-control" name="alterDataSource" id="alterDataSource">

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="alterExcelFile" class="col-sm-2 control-label">上传表格</label>

                        <div class="col-sm-10">
                            <input type="file" id="alterExcelFile" name="alterExcelFile"><span>不选择，默认用原来的模板</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="alterSheetNames" class="col-sm-2 control-label">需要发送sheet名称</label>

                        <div class="col-sm-10">
                            <input type="text" id="alterSheetNames" class="form-control" name="alterSheetNames"
                                   placeholder="填写EXCEL中的需要发送的sheet名称，如有多个Sheet，用*分割，如：Sheet1*Sheet2">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">邮件选项</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" id="alterIsSendEmail" name="alterIsSendEmail" onchange="alterEmailSelect(this)"> 发送邮件
                        </label>
                    </div>
                    <div class="form-group" id="alterEmailGroup">
                        <label for="alterEmailRule" class="col-sm-2 control-label">邮件分组</label>

                        <div class="col-sm-10">
                            <select class="form-control" name="alterEmailRule" id="alterEmailRule">

                            </select>
                        </div>
                    </div>
                    <div class="form-group" id="alterEmailSub">
                        <label for="alterEmailSubject" class="col-sm-2 control-label">邮件主题</label>

                        <div class="col-sm-10">
                            <input name="alterEmailSubject" type="text" class="form-control" id="alterEmailSubject"
                                   placeholder="邮件主题">
                        </div>
                    </div>

                    <div class="form-group" id="alterEmailCont">
                        <label for="emailContent" class="col-sm-2 control-label">邮件内容</label>

                        <div class="col-sm-10">
                            <textarea class="form-control"  name="alterEmailContent" id="alterEmailContent"
                                      rows="2"></textarea>
                        </div>
                    </div>
                    <div class="form-group" id="alterEmailFujian">
                        <label class="col-sm-2 control-label">邮件附件</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" id="alterIsSendExcel" name="alterIsSendExcel" checked> 发送Excel
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" id="alterIsSendPicture" name="alterIsSendPicture" checked>发送图片
                        </label>
                        <span  class="checkbox-inline" style="color:red">[Excel和图片至少选择一项]</span>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">易信选项</label>
                        &nbsp;&nbsp;
                        <label class="checkbox-inline">
                            <input type="checkbox" onchange="alterYixinSelect(this)" id="alterIsSendYixin" name="alterIsSendYixin">
                            发送易信
                        </label>
                    </div>
                    <div class="form-group" style="display: none;" id="alterYixin">
                        <label for="alterYixinNames" class="col-sm-2 control-label">易信接收人</label>

                        <div class="col-sm-10">
                            <input type="text" id="alterYixinNames" class="form-control" name="alterYixinNames"
                                   placeholder="填写易信接收人的名字，必须先加好友。如有多个，用,分割，如：张三,李四">
                        </div>
                    </div>

                    <div class="form-group" align="right">
                        <button type="submit" id="alter" name="alter" class="btn btn-default">修改
                        </button>
                        &nbsp;&nbsp;&nbsp;
                    </div>
                    <input type="hidden" name="excelId" id="excelId" value="" />
                    <input type="hidden" name="pictureId" id="pictureId" value="" />
                    <input type="hidden" name="taskId" id="taskId" value="" />
                    <input type="hidden" name="isAutoRun" id="isAutoRun" value="" />
                    <input type="hidden" name="taskDetailId" id="taskDetailId" value="" />
                    <input type="hidden" name="taskAliasName" id="taskAliasName" value="" />
                    <input type="hidden" name="taskStatus" id="taskStatus" value="" />

                </form>

            </div>

        </div>
    </div>
</div>

<!-- Table -->
<table class="table" style="font-family:微软雅黑;">
    <tr>

        <th>序号</th>
        <th>任务名</th>
        <th>发送规则</th>
        <th>任务描述</th>
        <th>是否自动执行</th>
        <th>状态</th>
        <th>操作</th>

    </tr>
    <%int i = 0;%>
    <c:forEach items="${taskList}" var="list">
        <tr>

            <td><%=++i%>
            </td>
            <td>${list.taskAliasName}</td>
            <td>${list.cronExpression}</td>
            <td>${list.taskDesc}</td>
            <td>
                <c:if test="${list.isAutoRun==1}">自动</c:if>
                <c:if test="${list.isAutoRun==0}">手动</c:if>
            </td>
            <td>
                <c:if test="${list.taskStatus=='1'}">
                    执行中
                </c:if>
                <c:if test="${list.taskStatus=='0'}">
                    待执行
                </c:if>
                <c:if test="${list.taskStatus=='2'}">
                    暂停中
                </c:if>
                <c:if test="${list.taskStatus=='999'}">
                    异常
                </c:if>
            </td>

            <td>
                <c:if test="${list.taskStatus=='0'}">

                    <a href="<%= basePath %>/run?taskDetailId=${list.taskDetailModelId}">执行</a>|
                    <a href="#" onclick="runOnceNow('${list.taskDetailModelId}');">立即执行一次</a>|

                </c:if>
                <c:if test="${list.taskStatus=='1'}">

                    <a href="<%= basePath %>/pauseTask?taskDetailId=${list.taskDetailModelId}">暂停</a>|
                    <a href="#" onclick="runOnceNow('${list.taskDetailModelId}');">立即执行一次</a>|


                </c:if>
                <c:if test="${list.taskStatus=='2'}">

                    <a href="<%= basePath %>/resumeTask?taskDetailId=${list.taskDetailModelId}">恢复</a>|

                </c:if>
                <c:if test="${list.taskStatus=='999'}">
                    <a href="<%= basePath %>/run?taskDetailId=${list.taskDetailModelId}">重新执行</a>|
                </c:if>
                <a href="#" onclick="alterData('${list.taskDetailModelId}');" data-toggle="modal" data-target="#alterModal">修改</a>|
                <a href="<%= basePath %>/taskDelete?taskDetailId=${list.taskDetailModelId}">删除</a>|<a
                    href="#" data-toggle="modal" data-target="#lookModal"
                    onclick="lookDetail('${list.taskDetailModelId}');">查看详情</a>|
                <a href="<%= basePath %>/downExcelTemplate?taskDetailId=${list.taskDetailModelId}">下载Excel模板</a>
                    <%--<a href="#" data-toggle="modal" data-target="#alterModal" onclick="queryAlterTask('${list.taskDetailModelId}')">修改</a>--%>

            </td>
        </tr>
    </c:forEach>

</table>
</div>

</div>
<!-- /container -->


<jsp:include page="bottom.jsp" flush="true"/>


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

<script src="static/js/jquery.min.js"></script>
<script src="static/js/jquery.json.min.js"></script>
<script src="static/css/dist/js/bootstrap.min.js"></script>
<script src="static/css/assets/js/docs.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="static/css/assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="static/js/CommonPerson.js"></script>
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
-->
<script>
    $(document).ready(function () {
        /* 获取数据源 */
        $.post("loadDataBase", function (data) {

            var jsonObj = data;
            for (var i = 0; i < jsonObj.length; i++) {
                var $option = $("<option></option>");
                $option.attr("value", jsonObj[i][0]);
                $option.text(jsonObj[i][1]);
                $("#dataSource").append($option);
            }
            for (var i = 0; i < jsonObj.length; i++) {
                var $option = $("<option></option>");
                $option.attr("value", jsonObj[i][0]);
                $option.text(jsonObj[i][1]);
                $("#alterDataSource").append($option);
            }
        });
        $.post("loadEmail", function (data) {

            var jsonObj = data;
            for (var i = 0; i < jsonObj.length; i++) {
                var $option = $("<option></option>");
                $option.attr("value", jsonObj[i][0]);
                $option.text(jsonObj[i][1]);
                $("#emailRule").append($option);
            }
            for (var i = 0; i < jsonObj.length; i++) {
                var $option = $("<option></option>");
                $option.attr("value", jsonObj[i][0]);
                $option.text(jsonObj[i][1]);
                $("#alterEmailRule").append($option);
            }
        });

    });
    function runOnceNow(taskDetailModelId) {
        /* 获取数据源 */
//        $.get("runOnce?taskDetailId="+taskDetailModelId, function (data) {
//            alter(data);
//        });
//        var obj={};
//        obj["taskDetailId"]=taskDetailModelId;
        CommonPerson.Base.LoadingPic.FullScreenShow();
        ///return false;
        $.ajax({
            url: "<%= basePath %>/runOnce?taskDetailId=" + taskDetailModelId,
            type: "GET",
            contentType: 'application/json;charset=utf-8', //设置请求头信息
            dataType: "json",
            //data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
            data: "{}",            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
            success: function (data) {
                alert(JSON.stringify(data));
                CommonPerson.Base.LoadingPic.FullScreenHide();
            },
            error: function (res) {
                alert(res.responseText);
                CommonPerson.Base.LoadingPic.FullScreenHide();
            }
        });

    }

    function lookDetail(taskDetailModelId) {
        $.ajax({
            url: "<%= basePath %>/lookTaskDetail?taskDetailId=" + taskDetailModelId,
            type: "GET",
            contentType: 'application/json;charset=utf-8', //设置请求头信息
            dataType: "json",
            //data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
            data: "{}",            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
            success: function (data) {
                document.getElementById("excelFileLookLook").innerText = data.excel.templateName;
                document.getElementById("sheetNamesLook").innerText = data.picture.picSheetNames;
                document.getElementById("taskNameLook").innerText = data.taskDetail.taskAliasName;
                document.getElementById("cronExpressionLook").innerText = data.taskDetail.cronExpression;
                document.getElementById("taskDescLook").innerText = data.taskDetail.taskDesc;
                document.getElementById("dataSourceLook").innerText = data.dataSource.dataSourceName;
                document.getElementById("emailRuleLook").innerText = data.email.emailName;

                document.getElementById("lookEmailSubject").innerText = data.emailSubject;
                $("#lookEmailContent").attr("disabled",false);
                document.getElementById("lookEmailContent").value = data.emailContent;
                $("#lookEmailContent").attr("disabled",true);

                document.getElementById("lookYixinNames").innerText = data.yixinReceivers;
                $("#lookIsSendPicture").attr("disabled",false);
                $("#lookIsSendPicture").attr("checked",data.isSendPicture=="1"?true:false);
                $("#lookIsSendPicture").attr("disabled",true);
                $("#lookIsSendExcel").attr("disabled",false);
                $("#lookIsSendExcel").attr("checked", data.isSendExcel=="1"?true:false);
                $("#lookIsSendExcel").attr("disabled",true);

                //是否发送邮件
                console.log(data.isSendEmail);
                if(data.isSendEmail=="1"){
                    $("#lookEmailSub").show();
                    $("#lookEmailCont").show();
                    $("#lookEmailFujian").show();
                    $("#lookEmailGroup").show();
                    $("#lookIsSendEmail").attr("disabled",false);
                    $("#lookIsSendEmail").attr("checked",true);
                    $("#lookIsSendEmail").attr("disabled",true);

                }else{
                    $("#lookEmailSub").hide();
                    $("#lookEmailCont").hide();
                    $("#lookEmailFujian").hide();
                    $("#lookSheet").hide();
                    $("#lookEmailGroup").hide();
                    $("#lookIsSendEmail").attr("disabled",false);
                    $("#lookIsSendEmail").attr("checked",false);
                    $("#lookIsSendEmail").attr("disabled",true);

                }
                //是否发送易信
                if(data.isSendYixin=="1"){
                    $("#lookYixin").show();
                    $("#lookIsSendYixin").attr("disabled",false);
                    $("#lookIsSendYixin").attr("checked",true);
                    $("#lookIsSendYixin").attr("disabled",true);

                }else{
                    $("#lookYixin").hide();
                    $("#lookIsSendYixin").attr("disabled",false);
                    $("#lookIsSendYixin").attr("checked",false);
                    $("#lookIsSendYixin").attr("disabled",true);

                }
                // alert(JSON.stringify(data));
            },
            error: function (res) {
                alert(res.responseText);
            }
        });
    }


    function alterData(taskDetailModelId) {
        $.ajax({
            url: "<%= basePath %>/lookTaskDetail?taskDetailId=" + taskDetailModelId,
            type: "GET",
            contentType: 'application/json;charset=utf-8', //设置请求头信息
            dataType: "json",
            //data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法
            data: "{}",            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
            success: function (data) {
                document.getElementById("alterTaskName").value = data.taskDetail.taskAliasName;
                document.getElementById("alterTaskName").disabled=true;
                document.getElementById("alterCronExpression").value = data.taskDetail.cronExpression;
                document.getElementById("alterTaskDesc").value = data.taskDetail.taskDesc;
                document.getElementById("alterSheetNames").value = data.picture.picSheetNames;
                document.getElementById("alterEmailSubject").value = data.emailSubject;
                document.getElementById("alterEmailContent").value = data.emailContent;
                document.getElementById("alterYixinNames").value = data.yixinReceivers;
                document.getElementById("excelId").value = data.excelId;
                document.getElementById("pictureId").value = data.pictureId;
                document.getElementById("taskId").value = data.taskModelId;
                document.getElementById("isAutoRun").value = data.taskDetail.isAutoRun;
                document.getElementById("taskDetailId").value = data.taskDetailId;
                document.getElementById("taskAliasName").value = data.taskDetail.taskAliasName;
                document.getElementById("taskStatus").value = data.taskDetail.taskStatus;




                $("#alterDataSource").val(data.dataSourceId);
                $("#alterEmailRule").val(data.emailId);

                $("#alterIsSendPicture").attr("checked",data.isSendPicture=="1"?true:false);
                $("#alterIsSendExcel").attr("checked", data.isSendExcel=="1"?true:false);
                //是否发送邮件
                console.log(data.isSendEmail);
                if(data.isSendEmail=="1"){
                    $("#alterEmailSub").show();
                    $("#alterEmailCont").show();
                    $("#alterEmailFujian").show();
                    $("#alterEmailGroup").show();
                    $("#alterIsSendEmail").attr("checked",true);

                }else{
                    $("#alterEmailSub").hide();
                    $("#alterEmailCont").hide();
                    $("#alterEmailFujian").hide();
                    $("#alterSheet").hide();
                    $("#alterEmailGroup").hide();
                    $("#alterIsSendEmail").attr("checked",false);

                }
                //是否发送易信
                if(data.isSendYixin=="1"){
                    $("#alterYixin").show();
                    $("#alterIsSendYixin").attr("checked",true);
                }else{
                    $("#alterYixin").hide();
                    $("#alterIsSendYixin").attr("checked",false);
                }

//                document.getElementById("excelFileLookLook").innerText = data.excel.templateName;
//                document.getElementById("sheetNamesLook").innerText = data.picture.picSheetNames;
//
//                document.getElementById("dataSourceLook").innerText = data.dataSource.dataSourceName;
//                document.getElementById("emailRuleLook").innerText = data.email.emailName;

                // alter(JSON.stringify(data));
            },
            error: function (res) {
                alert(res.responseText);
            }
        });
    }

    function yixinSelect(yixin){
        if(yixin.checked){
            $("#yixin").show();
        }else{
            $("#yixin").hide();
        }
    }
    function alterYixinSelect(yixin){
        if(yixin.checked){
            $("#alterYixin").show();
        }else{
            $("#alterYixin").hide();
        }
    }

    function pictureSelect(picture){
        if(picture.checked){
            $("#sheet").show();
        }else{
            $("#sheet").hide();
        }
    }

    function alterPictureSelect(picture){
        if(picture.checked){
            $("#alterSheet").show();
        }else{
            $("#alterSheet").hide();
        }
    }

    function emailSelect(email){
        if(email.checked){
            $("#emailSub").show();
            $("#emailCont").show();
            $("#emailFujian").show();
            $("#emailGroup").show();
        }else{
            $("#emailSub").hide();
            $("#emailCont").hide();
            $("#emailFujian").hide();
            $("#sheet").hide();
            $("#emailGroup").hide();
            $("#isSendPicture").attr("checked",false);
            $("#isSendExcel").attr("checked",false);
        }
    }

    function alterEmailSelect(email){
        if(email.checked){
            $("#alterEmailSub").show();
            $("#alterEmailCont").show();
            $("#alterEmailFujian").show();
            $("#alterEmailGroup").show();
        }else{
            $("#alterEmailSub").hide();
            $("#alterEmailCont").hide();
            $("#alterEmailFujian").hide();
            $("#alterSheet").hide();
            $("#alterEmailGroup").hide();
            $("#alterIsSendPicture").attr("checked",false);
            $("#alterIsSendExcel").attr("checked",false);
        }
    }



</script>
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<script>


    <%--function queryAlterTask(taskDetailId) {--%>
        <%--//点击修改按钮，所做的操作--%>
        <%--//这个是点击修改链接。。。。的方法--%>


        <%--var dataObj = {};--%>
        <%--dataObj = {"taskDetailModelId": taskDetailId};--%>

        <%--jQuery.ajax({--%>
            <%--url: "<%= basePath %>/queryTaskInfo?taskDetailId=" + taskDetailId,--%>
            <%--type: "POST",--%>
            <%--contentType: 'application/json;charset=utf-8', //设置请求头信息--%>
            <%--dataType: "json",--%>
            <%--//data: JSON.stringify(customerArray),    //将Json对象序列化成Json字符串，JSON.stringify()原生态方法--%>
            <%--data: jQuery.toJSON(dataObj),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js--%>
            <%--success: function (data) {--%>

                <%--var taskDetailModelId = JSON.parse(data.info).taskDetailModelId;--%>
                <%--var taskName = JSON.parse(data.info).taskName;--%>
                <%--var cronExpression = JSON.parse(data.info).cronExpression;--%>
                <%--var taskDesc = JSON.parse(data.info).taskDesc;--%>
                <%--var isAutoRun = JSON.parse(data.info).isAutoRun;--%>
                <%--var dataSourceModelId = JSON.parse(data.info).dataSourceModelId;--%>
                <%--var emailModelId = JSON.parse(data.info).emailModelId;--%>

                <%--document.getElementById("alterTaskName").value = taskName;--%>
                <%--document.getElementById("alterCronExpression").value = cronExpression;--%>
                <%--document.getElementById("alterTaskDesc").value = taskDesc;--%>
                <%--if (isAutoRun == 1) {--%>
                    <%--document.getElementById("alterIsAutoRun1").checked = true;--%>
                <%--} else {--%>
                    <%--document.getElementById("alterIsAutoRun0").checked = false;--%>
                <%--}--%>
                <%--var selectSource = document.getElementById("alterDataSource");--%>
                <%--for (var i = 0; i < selectSource.options.length; i++) {--%>
                    <%--if (selectSource.options[i].value == dataSourceModelId) {--%>
                        <%--selectSource.options[i].selected = true;--%>
                        <%--break;--%>
                    <%--}--%>
                <%--}--%>

                <%--var alterEmailRule = document.getElementById("alterEmailRule");--%>
                <%--for (var i = 0; i < alterEmailRule.options.length; i++) {--%>
                    <%--if (alterEmailRule.options[i].value == emailModelId) {--%>
                        <%--alterEmailRule.options[i].selected = true;--%>
                        <%--break;--%>
                    <%--}--%>
                <%--}--%>

                <%--jQuery("#content").html(JSON.stringify(data));--%>
            <%--},--%>
            <%--error: function (res) {--%>
                <%--alert(res.responseText);--%>
            <%--}--%>
        <%--});--%>
    <%--}--%>


</script>
</body>
</html>
